<template>
  <div class="box">
    <div class="alogin"><h1>STAKESTORE后台管理员登录</h1></div>
    <div style="margin: 20px"></div>
    <el-form :label-position="labelPosition" :model="formLabelAlign">
      <el-form-item label="管理员账号">
        <el-input v-model="formLabelAlign.username"></el-input>
      </el-form-item>
      <el-form-item label="管理员密码">
        <el-input type="password" v-model="formLabelAlign.password"></el-input>
      </el-form-item>
      <el-row>
        <el-button type="info" @click="adminLand()">登录</el-button>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      labelPosition: "right",
      formLabelAlign: {
        username: "",
        password: "",
      },
    };
  },
  methods: {
    adminLand() {
      axios
        .post("http://localhost:8081/admin/adminLand", this.formLabelAlign)
        .then((res) => {
          let { code, msg, data } = res.data;
          if (code != 200) return this.$message.error(msg);
          this.$message.success("登录成功");
          window.sessionStorage.setItem("adminid", data.id);
          window.sessionStorage.setItem("adminname", data.username);
          this.$router.push({ path: "/admin" });
        });
    },
  },
};
</script>
<style scoped>
* {
  margin: 0px;
  padding: 0px;
}
.box {
  height: 100vh;
  background: url(../../assets/img/chinaskate.png);
  text-align: center;
  padding-top: 172px;
}
.alogin {
  margin-top: 20px;
  color: white;
  margin: 0 auto;
  height: 120px;
  width: 326px;
}
form.el-form.el-form--label-right {
  width: 255px;
  margin: 0 auto;
}
button.el-button.el-button--info {
  width: 150px;
  height: 60px;
  margin-top: 20px;
}
::v-deep .el-form-item__label {
  text-align: right;
  vertical-align: middle;
  float: left;
  font-size: 14px;
  color: #f5f7fa;
  line-height: 40px;
  padding: 0 12px 0 0;
  box-sizing: border-box;
}
</style>
